import { Video, VideoSearchResult } from '@/types/video'
import axios from 'axios'

const api = axios.create({
  baseURL: process.env.VUE_APP_API_URL || 'http://localhost:3000/api'
})

export const videoService = {
  async searchVideos(query: string): Promise<VideoSearchResult[]> {
    const response = await api.get(`/videos/search?q=${encodeURIComponent(query)}`)
    return response.data
  },
  
  async getSuggestions(query: string): Promise<string[]> {
    const response = await api.get(`/videos/suggestions?q=${encodeURIComponent(query)}`)
    return response.data
  },

  async getVideoById(id: string): Promise<Video> {
    const response = await api.get(`/videos/${id}`)
    return response.data
  }
} 